#include<bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
struct Node{
    int d,v,a;
    bool flag = false;
};
Node c[100010];
struct Node2{
    int x,y;
};
Node2 p[100010];
int ans1,ans2,sp;
int qzh[100010];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    scanf("%d%d%d%d",&n,&m,&L,&V);
    while(T--){
        int ans1=0,ans2=0,sp;
     for(int i=1;i<=n;i++){
        scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&p[i].x);
    for(int i=1;i<=n;i++){
        if(c[i].v>V){
            ans1++;
        }
    }
    printf("%d %d\n",ans1,m-1);   
    }
    
    return 0;
}